<template>
	<view>
		<view class="u-search-box">
			<u-search placeholder="课程搜索" v-model="keyword" @input="" @search="searchcourse"></u-search>
		</view>
		<view>
			<uni-card isFull="false">
				<!--可删除 做成for循环-->
				<view class="test" v-for="(item,index) in courselist" :key="item">
					<uni-card margin="10rpx" isFull="true" @click="getCouse(item)">
						<image style=" width: 300rpx; height: 210rpx;" :src="item.img" mode="scaleToFill"></image>
						<view style="height: 30px; display: flex; align-items: center; text-align: center;">{{item.courseName}}</view>
						<view style="margin-top: 5px;"><uni-rate :disabled="true" :size="10" :max="5" :value="item.star"></uni-rate></view>
					</uni-card>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword: "",
				courselist: {}
			}
		},
		onLoad: function(op) {
			if (op) {
				console.log(op.value);
				this.searchcourse(op.value);
			}
		},
		onShow() {
		},
		methods: {
			getCouse(even) {
				console.log(even);
				uni.navigateTo({
				    url: '../mycourses/addCourse?id='+even.courseid,
				});
			},
			searchcourse(value) {
				console.log(value);
				this.$http("/search",{
					value
				})
				.then((res) =>{
					this.courselist = res;
					console.log(res);
				})
				console.log("搜索");
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 40rpx;
	}
	.test {
		height: 150px;
		width: 145px;
		margin: 10px, 10px, 10px, 10px;
		float: left;
	}
	.u-search-box {
		padding: 18rpx 30rpx;
	}
</style>
